<?php
use Core\Common\Common;
use Core\Enums\ErrorEnum;
use Core\Result\Result;
define("__ROOT__",__DIR__);
error_reporting(E_ALL^E_NOTICE^E_WARNING);
spl_autoload_register(function ($class_name) {
    if(is_file(str_replace("\\","/",$class_name) . '.php')){
        require_once('' . str_replace("\\","/",$class_name) . '.php');
    }
});
include __DIR__ . '/vendor/autoload.php';
$POST = Common::getPost();
$TARGET=$POST["c"];
$METHOD=$POST["a"];
if(empty($TARGET)){
    $TARGET=$_GET["c"];
    $METHOD=$_GET["a"];
    $callback = $_SERVER['REQUEST_URI'];
    $callback = explode('/',$callback);
    if(in_array('index.php',$callback) && isset($callback[2]) && isset($callback[3])){
        $TARGET = $_REQUEST['c'] = $callback[2];
        $METHOD = $_REQUEST['a'] = $callback[3];
    }
}
//判断文件是否存在
if (!file_exists(__DIR__ . "/app/controller/$TARGET.php")){
    header("HTTP/1.0 404 Not Found");
    exit;
}
include __DIR__ . "/app/controller/$TARGET.php";
if (!function_exists("$METHOD")){
    header("HTTP/1.0 404 Not Found");
    exit;
}
$POST["userInfo"] = Common::getUserId($METHOD);
$METHOD($POST);